package cn.sh.tools.controller;

import cn.sh.tools.domain.dto.MailDto;
import cn.sh.tools.service.component.mail.MailComponent;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author shihao
 * @description 邮件
 */
@Api(tags = "邮件控制器")
@RestController
@RequestMapping(value = "/mail")
public class MailController {

    @Resource
    private MailComponent mailComponent;

    @ApiOperation("发送邮件")
    @RequestMapping(method = RequestMethod.POST, value = "/send")
    public String sendMail(@RequestBody MailDto mailDto) {
        return this.mailComponent.sendSimpleMail(mailDto.getTos(), mailDto.getCcs(),
                mailDto.getSubject(), mailDto.getText());
    }

}
